﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AdminLogin : System.Web.UI.Page
{
    Datautility du = new Datautility();
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        TextBox TxtUserName = (TextBox)Login1.FindControl("UserName");
        TextBox TxtPassword = (TextBox)Login1.FindControl("Password");
        Label TxtMsg = (Label)Login1.FindControl("FailureText");
        
        DataSet ds = new DataSet();
        ds.ReadXml(Server.MapPath("~/App_Data/Admin.xml"));
        //LblMsg.Text = ds.Tables[0].Rows.Count.ToString();

        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {

            DataTable dt = ds.Tables[0];
            //TxtUserName.Text = string.Empty;
            //TxtPassword.Text = string.Empty;
            if ((dt.Rows[i]["username"].ToString() == TxtUserName.Text) && (dt.Rows[i]["password"].ToString() == TxtPassword.Text))
            {
                e.Authenticated = true;
                Response.Redirect("Main/Admin/ViewCompany.aspx");
                TxtMsg.Text = "username or password is correct";
                break;
            }

        }
    }
    protected void LoginButton_Click(object sender, EventArgs e)
    {

    }
}
